<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<script type="text/javascript" src="../js/prototype.js"></script>
<script language="Javascript">
function setHiddenTestBoxValue(chkBox, hiddenBox){
	if(document.getElementById(chkBox).checked){
		document.getElementById(hiddenBox).value = '1';
	}else{
		document.getElementById(hiddenBox).value = '0';
	}
}

function fnUpdate()
{	
	document.systemVariableForm.screen_type.value="Edit";
	document.systemVariableForm.action='/saveSystemVariables.do?';
	document.systemVariableForm.submit();
}
</script>
<html:form action="/systemVariable" >
	
<html:hidden name="systemVariableForm" property="screen_type"/>	
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
  	<tr>
    	<td class="formbg" valign="top">
    		<table width="100%" border="0" cellspacing="0" cellpadding="0">
  				<tr>
    				<td>
    					<table width="100%" border="0" cellspacing="4" cellpadding="0">
							<tr>
								<td>&nbsp;</td>	
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp;</td>
								<td>&nbsp</td>
							</tr>
							<tr>
								<td colspan="6"><jsp:include page="showErrorMessage.jsp" /></td>
							</tr>
							<%int i =0;%>
							<logic:iterate name="systemVariableForm" property="systemVariableList" id="systemVariableVO">
							<tr>
								<td>&nbsp;</td>
								<td class="formText"><bean:write name="systemVariableVO" property="variableName"/></td>
								<td valign="middle">
								<logic:equal name="systemVariableVO" property="variableType" value="1">

								<input type="hidden" name="variableName"  value="<bean:write name="systemVariableVO" property="variableName"/>" />
								<input type="hidden" name="variableValue" id="<%=i%>systemVariable" value="<bean:write name="systemVariableVO" property="variableValue"/>" />
								<logic:equal name="systemVariableVO" property="variableValue" value="1">
								<input type="checkbox" name="tempChk" id="<%=i%>tempChk" checked onclick="javacript:setHiddenTestBoxValue('<%=i%>tempChk','<%=i%>systemVariable');"/>
								</logic:equal>
								<logic:notEqual name="systemVariableVO" property="variableValue" value="1">
								<input type="checkbox" name="tempChk" id="<%=i%>tempChk"  onclick="javacript:setHiddenTestBoxValue('<%=i%>tempChk','<%=i%>systemVariable');"/>
								</logic:notEqual>
								
								</logic:equal>

								<logic:equal name="systemVariableVO" property="variableType" value="2">
								<input type="hidden" name="variableName"  value="<bean:write name="systemVariableVO" property="variableName"/>" />
								<input type="text" class="form1" name="variableValue" id="<%=i%>systemVariable" value="<bean:write name="systemVariableVO" property="variableValue"/>" />								
								
								</logic:equal>
								</td>
								<td class="formText"></td>
								<td valign="middle"></td>
								<td >&nbsp</td>
							</tr>
							<%i++;%>
							</logic:iterate>
							<tr>								
								<td colspan="6">&nbsp</td>
							</tr>
							<tr>								
								<td colspan="6"><div align="center">
					        					<logic:equal name="systemVariableForm" property="screen_type" value="Edit">							
													<input type="button" class="imageButton" value="Update" onClick="javascript:fnUpdate()">							
												</logic:equal>
												<logic:equal name="systemVariableForm" property="screen_type" value="">
													<input type="button" class="imageButton" value="Submit" onClick="javascript:fnSubmit()">
												</logic:equal>
					                        	</div></td>
							</tr>
							<tr>								
								<td colspan="6">&nbsp</td>
							</tr>
							<tr>								
								<td colspan="6" height="100">&nbsp</td>
							</tr>
							<tr>
					    		<td width="100%" colspan="6">
					    			<table width="100%" border="0" cellspacing="0" cellpadding="0">
					      				<tr>
					        				<td class="lowerCorner1"></td>
					        				<td class="lowerbg">					        					
					                        </td>
					        				<td class="lowerCorner2"></td>
					      				</tr>
					    			</table>
					    		</td>
					  		</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>				
	<logic:equal name="systemVariableForm" property="screen_type" value="View">
		<script language="JavaScript">	
			var elements = document.forms[0].elements;
			var type = "";
			for(j=0;j<elements.length;j++){
				type = elements[j].type;
				if(type == 'text' || type == 'select-one' || type == 'radio' || type == 'checkbox' || type == 'button' || type == 'textarea') {
					elements[j].disabled=true;
				}
			}
		</script>
	</logic:equal>	
</html:form>